#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : lee

import sys
import os
import logging
import re
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
    import jarryLibs.mayakit.MayaUtils as mu
    reload(mu)
except:
    pass

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class CfxHairShaderCheck(CheckBase):
    def __init__(self):
        super(CfxHairShaderCheck, self).__init__()
        pass

    def check_hair_shader_standard(self):
        lambert_sets = self.get_lambert_sets()
        miss_node = []
        for mesh in cmds.ls(type="pgYetiMaya"):
            for set in lambert_sets:
                if cmds.sets(mesh, im=set):
                    miss_node.append(mesh)

        return miss_node

    def get_lambert_sets(self):
        sets = []
        for shader in cmds.ls(type="lambert"):
            for set in cmds.listConnections(shader + ".outColor"):
                sets.append(set)
        return sets

    def check(self):
        result_proc = self.check_hair_shader_standard()
        if result_proc:
            result_log = u'Error:%s\n' % result_proc
        else:
            result_log = u'Succeed:没有问题\n'

        return result_log

    def fix(self):
        pass
